<template>
    <div>
        <van-tabs>
            <van-tab title="可办理">
                <div :class="['order-box-group',showItem?'List-Down':'List-Up']">
                    <img class="defpageB" src="../assets/defaultpage/own-sale.png" v-if="receivedList.length==0&&!showItem" alt="">
                    
                    <div class="order-box" v-for="(item,index) in receivedList">
                        <div class="table-order-box">
                            <div class="order-left-img" :style="`background:url('http://www.starrymedia.vip${item.good.goods.left_img}')`"></div>
                            <div class="order-righr-text">
                                <van-cell-group>
                                    <van-cell title="订单编号" :value="item.order.order_sn" />
                                    <van-cell title="下单时间" :value="formateDate(item.order.add_time)" />
                                </van-cell-group>
                                <span class="order-money">￥{{item.order.total_amount}}</span>
                                <div class="order-btn-group">
                                    <span class="order-btn" @click="ApplyForAfterSales(item.order.order_id)">申请售后</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                
            </van-tab>
            <van-tab title="办理中">
                <div :class="['order-box-group',showItem?'List-Down':'List-Up']">
                    <img class="defpageB" src="../assets/defaultpage/own-sale.png" v-if="processList.length==0&&!showItem" alt="">

                    <div class="order-box" v-for="(item,index) in processList">
                        <div class="table-order-box">
                            <div class="order-left-img" :style="`background:url('http://www.starrymedia.vip${item.good.goods.left_img}')`"></div>
                            <div class="order-righr-text">
                                <van-cell-group>
                                    <van-cell title="订单编号" :value="item.order.refund_sn" />
                                    <van-cell title="下单时间" :value="formateDate(item.order.add_time)" />
                                </van-cell-group>
                                <span class="order-money">￥{{item.order.orders.total_amount}}</span>
                                <div class="order-btn-group">
                                    <span class="order-btn" v-if="item.order.status==0">审核中</span>
                                    <span class="order-btn order-btn-black"  v-if="item.order.status==1" @click="Jumpto({path:'/fillinlog',query:{reid:item.order.refund_id}})">回寄商品</span>
                                    <span class="order-btn order-btn-black" @click="confirm(item.order.refund_id)" v-if="item.order.status!=0">确认收货</span>
                                    <span class="order-btn" @click="Jumpto({path:'/AfterSalesDetails',query:{reid:item.order.refund_id}})">查看详情</span>
                                </div>
                            </div>
                        </div>
                    </div>

                    
                </div>
            </van-tab>
            <van-tab title="已完成">
                <div :class="['order-box-group',showItem?'List-Down':'List-Up']">
                    <img class="defpageB" src="../assets/defaultpage/own-order.png" v-if="overProList.length==0&&!showItem" alt="">

                    <div class="order-box" v-for="(item,index) in overProList">
                        <div class="table-order-box">
                            <div class="order-left-img" :style="`background:url('http://www.starrymedia.vip${item.good.goods.left_img}')`"></div>
                            <div class="order-righr-text">
                                <van-cell-group>
                                    <van-cell title="订单编号" :value="item.order.orders.order_sn" />
                                    <van-cell title="下单时间" :value="formateDate(item.order.add_time)" />
                                </van-cell-group>
                                <span class="order-money">￥{{item.order.orders.total_amount}}</span>
                                <div class="order-btn-group">
                                    <span class="order-btn" @click="Jumpto({path:'/AfterSalesDetails',query:{reid:item.order.refund_id}})">查看详情</span>
                                </div>
                            </div>
                        </div>
                    </div>
                    
                </div>
            </van-tab>
        </van-tabs>
    </div>
</template>
<script>
import {_confirmRefund} from '../service/order'
export default {
    props:['showItem','receivedList','processList','overProList'],
    data(){
        return{
            orderLogistics:true
        }
    },
    methods:{
        ApplyForAfterSales(id){
            this.$router.push({path:"/aftersale",query:{oid:id}})
        },
        Jumpto(key){
            this.$router.push(key)
        },
        formateDate(time){
            return moment(time*1000).format('YYYY-MM-DD HH:mm:ss')
        },
        confirm(id){
            let _this=this
            let uid=JSON.parse(localStorage.getItem("user")).user_id
            _confirmRefund({
                refund_id:id,
                user_id:uid
            }).then(res=>{
                console.log(res)
                if(res.errcode==1){
                    _this.$emit("Refresh")
                }
            })
        }
    }
}
</script>
<style lang="less" scoped>
    .font-SC(){
        font-family: "PingFang SC","Microsoft YaHei";
    }
    /deep/.van-tabs__wrap{
        height: 53px;
        background-color: #f8f8f8;
    }
    /deep/.van-tabs__nav--line{
        height: 53px; 
        width: 229px;   
        margin: 0 auto;
        background-color: #f8f8f8;
        margin-left: 100px
    }
    /deep/.van-tab__text{
        .font-SC();
        font-weight: bold;
        color: #999;
        font-size: 12px;
    }
    /deep/.van-tabs__line{
        width: 30px !important;
        height: 3px;
        background-color: #000;
        bottom: 30px;
        box-shadow: 2px 2px 4px rgba(51, 51, 51, .47);
    }
    /deep/.van-tab--active .van-tab__text{
        color: #333;
    }


    .order-box-group{
        width: 100%;
        position: fixed;
        top: 256px;
        bottom: 0;
        left: 0;
        right: 0;
        overflow-y: auto;
        .defpageB{
            width: 127px;
            position: relative;
            top: 50px;
            left: 35%;
        }
        .order-box{
            width: 100%;
            height: auto;
            padding: 15px 15px 0 15px;
            background-color: #fff;
            margin-top: 10px;
            &:first-child{
                margin-top: 0px;
            }
            .table-order-box{
                width: 100%;
                height: 100px;
                .top-icon{
                    width: 21px;
                    float: left;
                }
                .order-left-img{
                    display: inline-block;
                    width: 65px;
                    height: 77px;
                    background-position: center !important;
                    background-size: contain !important;
                    background-repeat: no-repeat !important;
                    &::before{
                        content: "";
                        background-image: url('../assets/img/own-fan-medal.png');
                        background-size: 21px auto;
                        background-repeat: no-repeat;
                        margin-left: 15px;
                        margin-top: -15px;
                        width: 21px;
                        height: 30px;
                        display: inline-block;
                    }
                }
                .order-righr-text{
                    width: 253px;
                    display: inline-block;
                    height: 77px;
                    margin-left: 25px;
                    vertical-align: top;
                    /deep/.van-cell{
                        padding: 0;
                        .font-SC();
                        font-size: 12px;
                        color: #999;
                        line-height: 22px;
                    }
                    /deep/.van-cell:not(:last-child)::after{
                        display: none;
                    }
                    /deep/.van-cell__value{
                        font-family: "DINPro Medium";
                    }

                    p{
                        margin-bottom: 0;
                        .order-attr{
                            font-family: "DINPro-Bold";
                            font-size: 12px;
                            color: #999;
                            line-height: 21px;
                            margin-right: 26px;
                        }
                    }
                    .order-btn-group{
                        width: 58%;
                        float: right;
                        .order-btn{
                            display: inline-block;
                            float: right;
                            width: 60px;
                            height: 20px;
                            border: 1px solid #ccc;
                            border-radius: 5px;
                            .font-SC();
                            font-size: 12px;
                            color: #999;
                            text-align: center;
                            margin-left:10px;
                            margin-top: 12px;
                        }
                        .order-btn-black{
                            color: #fff;
                            background-color: #000;
                        }
                    }
                }
            }
            .order-logistics-info{
                width: 100%;
                height: auto;
                padding-top: 15px;
                background-color: #fff;
                padding-bottom: 15px;
                border-top: 1px solid #ccc;
                .log-info-title{
                    width: 100%;
                    .font-SC();
                    font-weight: bold;
                    font-size: 15px;
                    color: #333;
                }
                /deep/.van-cell{
                    padding: 0;
                    .font-SC();
                    font-size: 12px;
                    color: #999;
                    line-height: 22px;
                }
                /deep/.van-cell:not(:last-child)::after{
                    display: none;
                }
            }


        }
    }


    .List-Up{
        animation: ListUp ease .2s forwards;
        -moz-animation:ListUp ease .2s forwards ; /* Firefox */
        -webkit-animation:ListUp ease .2s forwards ; /* Safari and Chrome */
        -o-animation:ListUp ease .2s forwards ; /* Opera */
    }
    .List-Down{
        animation: ListDown ease .2s forwards;
        -moz-animation:ListDown ease .2s forwards ; /* Firefox */
        -webkit-animation:ListDown ease .2s forwards ; /* Safari and Chrome */
        -o-animation:ListDown ease .2s forwards ; /* Opera */
    }
    @keyframes ListUp {
        from{
            top: 2000px;
        }
        to{
            top: 256px;
        }
    }
    @keyframes ListDown {
        from{
            top: 256px;
        }
        to{
            top: 2000px;
        }
    }
</style>